home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / CIT.v4 / Demo / LabelDemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  2.3 KB  |  124 lines

  1. #include <CITGroup.h>
  2. #include <CITLabel.h>
  3.  
  4. #include <intuition/screens.h>
  5. #include <graphics/text.h>
  6. #include <stdlib.h>
  7.  
  8. __chip UWORD image_data[] =
  9. {
  10.   /* Plane 0 */
  11.   0x0000, 0x0000,
  12.   0x7F00, 0x0000,
  13.   0x4180, 0x0000,
  14.   0x4140, 0x0000,
  15.   0x4120, 0x4000,
  16.   0x41F0, 0x6000,
  17.   0x401B, 0xF000,
  18.   0x401B, 0xF800,
  19.   0x401B, 0xF000,
  20.   0x4018, 0x6000,
  21.   0x4018, 0x4000,
  22.   0x4018, 0x0000,
  23.   0x4018, 0x0000,
  24.   0x7FF8, 0x0000,
  25.   0x1FF8, 0x0000,
  26.   0x0000, 0x0000,
  27.   /* Plane 1 */
  28.   0x0000, 0x0000,
  29.   0x0000, 0x0000,
  30.   0x3E00, 0x0000,
  31.   0x3E80, 0x0000,
  32.   0x3EC0, 0x0000,
  33.   0x3E00, 0x0000,
  34.   0x3FE0, 0x0000,
  35.   0x3FE0, 0x0000,
  36.   0x3FE0, 0x0000,
  37.   0x3FE0, 0x0000,
  38.   0x3FE0, 0x0000,
  39.   0x3FE0, 0x0000,
  40.   0x3FE0, 0x0000,
  41.   0x0000, 0x0000,
  42.   0x0000, 0x0000,
  43.   0x0000, 0x0000
  44. };
  45.  
  46. struct Image image =
  47. {
  48.   0, 0, 22, 16, 2, image_data, 0x03, 0x00, NULL
  49. };
  50.  
  51. UWORD map[] = {BACKGROUNDPEN,SHADOWPEN};
  52.  
  53. class CITApp Application;
  54.  
  55. class CITWorkbench DemoScreen;
  56. class CITWindow    DemoWindow;
  57. class CITVGroup    winGroup;
  58. class CITLabel     label;
  59.  
  60. void CloseEvent();
  61.  
  62. int main(void)
  63. {
  64.   BOOL Error=FALSE;
  65.  
  66.   DemoScreen.InsObject(DemoWindow,Error);
  67.     DemoWindow.Position(30,30);
  68.     DemoWindow.CloseGadget();
  69.     DemoWindow.DragBar();
  70.     DemoWindow.DepthGadget();
  71.     DemoWindow.Activate();
  72.     DemoWindow.SizeGadget();
  73.     DemoWindow.IconifyGadget();
  74.     DemoWindow.Caption("Label Demo");
  75.     DemoWindow.CloseEventHandler(CloseEvent);
  76.     DemoWindow.InsObject(winGroup,Error);
  77.       winGroup.InsObject(label,Error);
  78.         label.Justification(LABEL_CENTRE);
  79.         label.Text("_Under-scored\nNot under-scored\n");
  80.         label.Text("An image:");
  81.         label.Image(&image);
  82.           label.Mapping(map);
  83.         label.Text("\nChange fonts,\n");
  84.           label.FGPen(3);
  85.           label.Font("emerald.font",18);
  86.         label.Text("and colours,");
  87.           label.FGPen(2);
  88.         label.Text(" and styles");
  89.           label.SoftStyle(FSF_BOLD);
  90.  
  91.   Application.InsObject(DemoScreen,Error);
  92.  
  93.  
  94.   // Ok?
  95.   if( Error )
  96.     return 10;
  97.  
  98.   Application.Run();
  99.  
  100.   Application.RemObject(DemoScreen);
  101.  
  102.   return 0;
  103. }
  104.  
  105. int repeatCount = 0;
  106.  
  107. void CloseEvent()
  108. {
  109.   repeatCount++;
  110.  
  111.   switch( repeatCount )
  112.   {
  113.     case 1:
  114.       DemoWindow.Position(50,50);
  115.       break;
  116.     case 2:
  117.       DemoWindow.Size(300,180);
  118.       break;
  119.     default:
  120.       Application.Stop();
  121.     break;
  122.   }
  123. }
  124.